home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-06 | 1.9 KB | 98 lines | [TEXT/MSET] |
- \ 28Oct94 dbh updated to 2.5 syntax
-
- (*
-
- A pushButton and checkBox+ will function as is without any required
- setup. They have default titles and positions, and will respond
- appropriately to mouse clicks. These controls are selection objects.
- Action handlers must be installed in order for these controls to actually
- do anything.
-
- *)
-
-
- :class pushButton super{ baseControl }
-
- dicAddr ACTION
- $16 cTitle
-
- :m INIT: ( x y addr len -- )
- put: cTitle
- puttopy: bounds
- puttopx: bounds ;m
-
- :m ACTION: \ ( cfa -- ) Sets the action for this control
- put: action ;m
-
- :m new: { wptr -- } \ must be compatible with selection objects
- wptr put: wind
- get: procID 8 and \ window font if true
- NIF 0 tFont 12 tSize ( Chicago 12 ) THEN
- get: cTitle mStringWidth ( dx) 5 + 17 ( dy) setsize: bounds
- get: procID konst pushButProc =
- NIF 16 0 stretch: bounds THEN \ must account for width of checkbox/radiobutton
- 0 wptr bounds ( rptr) get$: cTitle
- w 256 word0 word0 w 1 int: procid
- self \ refcon
- call NewControl put: ctlHndl
- ;m
-
- :m SETTITLE: \ ( addr len -- )
- put: cTitle
- alive?: self
- IF
- get: ctlHndl get$: cTitle call setCTitle
- THEN ;m
-
- :m GETTITLE: \ ( -- addr len )
- get: cTitle ;m \ we always maintain cTitle, alive or not
-
- :m CLASSINIT: \ Sets default control to a standard button
- konst pushButProc put: procID
- ['] null action: self
- 50 50 moveto: bounds
- " pushButton" put: cTitle ;m
-
- :m exec: ( part# -- )
- IF \ action only if in same control part
- get: action execute
- THEN ;m
-
- ;class
-
- :class CHECKBOX+ super{ pushButton }
-
- :m toggle:
- get: self
- IF 0
- ELSE 1
- THEN put: self ;m
-
- :m exec: ( part# -- )
- IF
- toggle: self
- get: action execute
- THEN ;m
-
- :m CLASSINIT:
- classinit: super
- konst checkBoxProc put: procID
- " Checkbox+" put: cTitle ;m
-
- ;class
-
-
- endload
-
- *** EXAMPLE USE
-
- selwindow w
- test: w
-
- pushButton b
- b add: w
-
- pushButton bb
- 20 20 moveto: bb
- bb add: w
-